package com.aj.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.aj.utils.Contants;

public class SetPasswordActivity extends BaseActivity {
	private Button ok;
	private String pageFlag;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_set_password);
		initView();
	}

	private void initView() {
		ok = (Button) findViewById(R.id.ok);
		setActionBarTitle(R.string.setpassword_title_text);
		pageFlag = getIntent().getStringExtra(Contants.PAGEFLAG_STRING);
		ClickEvent clickEvent = new ClickEvent();
		ok.setOnClickListener(clickEvent);
	}

	class ClickEvent implements OnClickListener {
		@Override
		public void onClick(View v) {
			Intent intent = null;
			switch (v.getId()) {
			case R.id.ok:
				if (pageFlag != null
						&& pageFlag.equals(Contants.REGISTER_PAGEFLAG_STRING)) {
					intent = new Intent(Contants.HOMEACTIVITY_ACTION);
					intent.putExtra(Contants.PAGEFLAG_STRING, pageFlag);
					startActivity(intent);
					if (LoginActivity.instance != null) {
						LoginActivity.instance.finish();
						LoginActivity.instance = null;
					}
				}
				if (EnterPhoneActivity.instance != null) {
					EnterPhoneActivity.instance.finish();
					EnterPhoneActivity.instance = null;
				}
				if (EnterVerificationCodeActivity.instance != null) {
					EnterVerificationCodeActivity.instance.finish();
					EnterVerificationCodeActivity.instance = null;
				}
				finish();
				break;
			default:
				break;
			}
		}
	}
}
